<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
	<title>前台学生注册页面</title>
	<link rel="icon" href="favicon.ico" type="image/ico">
	<meta name="keywords" content="后台管理系统">
	<meta name="description" content="后台管理系统">
	<meta name="author" content="soulCoder">

	<link rel="stylesheet" type="text/css" th:href="@{/static/other/css/style.css}" >

	<link rel="stylesheet" type="text/css" th:href="@{/static/other/css/other.css}" >
	
	<style>
		.tm_register_body{
			background:url('../../static/other/images/001.jpg');
			background-size:cover;
			-moz-background-size:cover;
			background-repeat:no-repeat;
		}
		.tm_register_container{ width:500px; margin:100px auto; clear:both}
		.tm_register_title{
			height:80px;
			margin:10px 0 15px 0;
			background:#fff;
			text-align:center;
			border-bottom:solid 1px #eee;
		}
		.tm_register_title img{
			height:50px;
		}
		.tm_register_title span{
			font-size:25px; 
			line-height:80px;
			font-family:'Microsoft Yahei',Tahoma, Geneva, 'Simsun';
		}
		.tm_register_form{ 
			width:100%; 
			height:630px;
			clear:both; 
			-moz-border-radius:8px;
			-webkit-border-radius:8px;
			border-radius:8px;
			padding:1px;
			background:#fff;
		}
		.tm_register_table{ width:400px; margin:20px auto;}
		.tm_register_table caption{text-align:center; margin:0 0 10px 0}
		.tm_register_table tr th{ width:100px;}
		.tm_register_table tr td{ width:300px; text-align:left}

		.tm_register_title_table{ width:400px; margin:0px auto;}
		.tm_register_title_table tr th{ width:100px;}
		.tm_register_title_table tr td{ width:300px; text-align:left}
		
		.tm_register_foot{ width:100%; line-height:20px; text-align:center; clear:both; margin:20px 0}
		
	</style>
	
  </head>
  
<body class="tm_register_body" style="">

	<div class="tm_register_container">
    	<div class="tm_register_form">
			<div class="tm_register_title">
				<table border="0" cellpadding="0" cellspacing="0" class="tm_register_title_table">
					<tbody><tr>
						<th><img th:src="@{/static/other/images/logo_min.png}" align="absmiddle"></th>
						<td>
							<span>注册新用户</span>
						</td>
					</tr>
				</tbody></table>
			</div>
			
			<form action="http://demo.tomexam.com/" id="form_register" method="post">
            <table border="0" cellpadding="5" cellspacing="0" class="tm_register_table">
				<caption>
					
						
							<p>填写以下表单信息，注册成为新用户</p>
						
						
					
				</caption>
                <tbody>
				<tr>
                    <th>用户名</th>
                    <td>
						<input type="text" class="validate[required,custom[onlyLetterNumberLine],minSize[6]] tm_txt" name="username" maxlength="30" value="" style="width:200px">
						<span class="tm_required">*</span> 
					</td>
                </tr>

				<tr>
					<th>昵 &nbsp; 称</th>
					<td>
						<input type="text" class="validate[required] tm_txt"  name="nickName" maxlength="30"  value="" style="width:200px">
						<span class="tm_required">*</span>
				
					</td>
				</tr>


				<tr>
                    <th>密 &nbsp; 码</th>
                    <td>
						<input type="password" class="validate[required] tm_txt" name="password" id="password" maxlength="30" value="" style="width:200px">
						<span class="tm_required">*</span>


					</td>
                </tr>

				<tr>
					<th>电话号码</th>
					<td>
						<input type="text" name="tel" class="tm_txt" size="50" maxlength="30" style="width:200px">
					</td>
				</tr>
				<tr>
                    <th>电子邮箱</th>
                    <td>
						<input type="text" name="email" class="tm_txt" size="50" maxlength="30" style="width:200px">
					</td>
                </tr>

				
				<tr>
                    <th>学生学号</th>
                    <td><input type="text" class="tm_txt" name="stuNum" maxlength="30" value="" style="width:200px"></td>
                </tr>
				
                <tr>
                    <th></th>
                    <td>
						<div style="margin-top:40px">
							
								
									<button type="button" class="tm_btn tm_btn_primary" style="width:50%" onclick="tm.doRegister();">提交</button>
								
								
							
							
							<button type="button" class="tm_btn" onclick="tm.doGoBack();" style="width:30%">返回</button>
						</div>
                    </td>
                </tr>
                <tr>
                    <th></th>
                    <td></td>
                </tr>
            </tbody></table>
			</form>
        </div>
		
		<div class="tm_register_foot">
			
			<div>Copyright自由如风 考试系统注册页</div>
		</div>
	</div>


	<script  th:src="@{/static/other/js/jquery.js}" type="text/javascript"></script>
	<script th:src="@{/static/other/js/baseutil.js}"  type="text/javascript"></script>
	<script th:src="@{/static/other/js/aes.js}"  type="text/javascript"></script>
	<script th:src="@{/static/other/js/pad-zeropadding-min.js}"  type="text/javascript"></script>
	<script th:src="@{/static/other/js/layer.js}"  type="text/javascript"></script>


	<link rel="stylesheet"  th:href="@{/static/other/css/validationEngine.jquery.css}" >
	<script th:src="@{/static/other/js/jquery.validationEngine.js}" ></script>
	
	
	<script th:src="@{/static/other/js/jquery.validationEngine-zh_CN.js}" ></script>
	

	

	<script type="text/javascript">
		$(document).ready(function(){ 
			tm_bindPasswordLevelChecker("u_userpass");
		}); 

		var tm = {
			doGoBack : function(){
				window.location.href = '/front/login';
			},



			doRegister : function(){

				var formcheck = $("#form_register").validationEngine('validate', {showOneMessage: true});

				if(!formcheck){
					return false;
				}

				var username = $("input[name='username']").val();
				var nickName = $("input[name='nickName']").val();
				var password = $("input[name='password']").val();
				var tel = $("input[name='tel']").val();
				var stuNum = $("input[name='stuNum']").val();
				var email = $("input[name='email']").val();


				if(baseutil.isEmpty(username)){
					alert('没有填写用户名');
					return;
				}
				if(baseutil.isEmpty(nickName)){
					alert('没有填写昵称');
					return;
				}
				if(baseutil.isEmpty(password)){
					alert('没有填写登录密码');
					return;
				}
				if(baseutil.isEmpty(tel)){
					alert('没有填写电话号码');
					return;
				}
				if(baseutil.isEmpty(email)){
					alert('没有填写邮箱');
					return;
				}
				if(baseutil.isEmpty(stuNum)){
					alert('没有填写学生学号');
					return;
				}


				$(".tm_btn_primary").text('提交...');
				var tmdata = {
						"username":username, "nickName":nickName, "password":password,
						"tel":tel, "stuNum":stuNum,
						"email":email, "t":Math.random()};
				
				$.ajax({
					type: "POST",
					url: "/stu/regStu",
					dataType: "json",
					data: tmdata,
					success: function(data){
						if(data){
							var isSuccess = data["isSuccess"];
							var ret_msg = data["message"];

							if(!isSuccess){
								alert(ret_msg);
								window.location.reload();
							}else{
								alert('注册成功!');
								window.location="/front/login";
							}
						}
					},
					error: function(){
						//$(".tm_btn_primary").text('登录');
						alert('系统忙，请稍后再试');
						window.location.reload();
					}
				}); 
			}
		};
	</script>



</body></html>